﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:ui="clr-namespace:ProjectEuler.UI"
             
             x:Name="This"
             x:Class="ProjectEuler.UI.InfoBar"
             x:ClassModifier="internal"
             
             >

    <Border Background="{DynamicResource {x:Static SystemColors.InfoBrushKey}}"
            BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
            BorderThickness="1"
            CornerRadius="2"
            Margin="4"
            Padding="4"
            SnapsToDevicePixels="True"
            TextBlock.Foreground="{DynamicResource {x:Static SystemColors.InfoTextBrushKey}}"
            >
        
        <Grid>
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            
            <Grid Grid.Column="0" 
                  DataContext="{Binding LastRunResult}"
                  VerticalAlignment="Top">
                
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="20" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Image Grid.Column="0"
                       Margin="1"
                       Height="14"
                       Source="{Binding WorstResult, Converter={StaticResource ConvertProblemStatusToImage}}"
                />

                <StackPanel Grid.Column="1" Orientation="Vertical" VerticalAlignment="Top">

                    <TextBlock Text="{Binding}" />

                </StackPanel>


            </Grid>

            <StackPanel Grid.Column="1" 
                        Orientation="Horizontal">

                <TextBlock Margin="0,0,5,0"
                           VerticalAlignment="Center"
                           Visibility="{Binding IsExecutingOrStopping, Converter={StaticResource ConvertBooleanToVisibility}}"
                           >
                    <Hyperlink Command="{x:Static ui:Commands.Cancel}" 
                               ui:TextBlockService.BoundText="{Binding Command.Text, RelativeSource={RelativeSource Self}}" 
                    />
                </TextBlock>

                <ProgressBar Width="80" 
                             Minimum="0"
                             Maximum="100"
                             Value="{Binding PercentComplete, Mode=OneWay}"
                             Visibility="{Binding IsExecutingOrStopping, Converter={StaticResource ConvertBooleanToVisibility}}"
                />

            </StackPanel> 

        </Grid>
    </Border>
</UserControl>
